//接口测试类,必须在桥接完成后且已经引入csg_uitl.js
var  _checkOk,_checkfail
//通讯回调
var _sucessRecall,_failRecall
//接口地址
var _serverpath

var initCheckServ = function(opt){
	_serverpath = opt.server
	_sucessRecall = opt.okfun
	_failRecall = opt.failfun
	if(typeof(opt.iscsg)!='undefined')
	 starCheck(opt.iscsg)
}
//启动检查
var starCheck = function(iscsg){
	if(iscsg)//南网鉴权模式
	  Cgs_token(_doCheckAjax_Native,"")
	else
	  _doCheckAjax_Native("")
}



//用原生ajax检查接口
var _doCheckAjax_Native = function(tokenstr) {
	var ajaxData = {};
	ajaxData.url = _serverpath;
	ajaxData.method = "GET";
	ajaxData.isBlock = true;
	ajaxData.successFunction = "_checkOk";
	ajaxData.failFunction = "_checkfail";
	//设置请求编码格式
	ajaxData.reqCharset = "UTF-8";
	//设置回应编码格式
	ajaxData.rspCharset = "UTF-8";
	//设置连接超时时间 10秒
	ajaxData.connectTimeout = 10;
	//设置读取超时时间 90秒
	ajaxData.timeout = 90;
	if (tokenstr.length > 0) {
		var requestHeader = '{"access_token":"' + tokenstr + '"}'
		ajaxData.requestHeader = eval("(" + requestHeader + ")")
	}
	var ajax = new DirectAjax(ajaxData);
	ajax.send();
}
//正确回文
_checkOk = function(data) {
   if(typeof(_sucessRecall)== 'function')
	_sucessRecall(data)
   else
    ExMobiWindow.alert(JSON.stringify(data))
}
//通信异常
_checkfail = function(data) {
   if(typeof(_failRecall)== 'function')
	_failRecall(data)
   else
    ExMobiWindow.alert(JSON.stringify(data))
}